home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / TexCopyX.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-01  |  7.3 KB  |  217 lines

  1. /*
  2.  * (c) Copyright 1995, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED
  4.  * Permission to use, copy, modify, and distribute this software for
  5.  * any purpose and without fee is hereby granted, provided that the above
  6.  * copyright notice appear in all copies and that both the copyright notice
  7.  * and this permission notice appear in supporting documentation, and that
  8.  * the name of Silicon Graphics, Inc. not be used in advertising
  9.  * or publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.
  11.  *
  12.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  13.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  14.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  15.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  16.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  17.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  18.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  19.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  20.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  21.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  22.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  23.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  *
  25.  * US Government Users Restricted Rights
  26.  * Use, duplication, or disclosure by the Government is subject to
  27.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  28.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  29.  * clause at DFARS 252.227-7013 and/or in similar or successor
  30.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  31.  * Unpublished-- rights reserved under the copyright laws of the
  32.  * United States.  Contractor/manufacturer is Silicon Graphics,
  33.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  34.  *
  35.  * Author: John Spitzer, SGI Applied Engineering
  36.  *
  37.  */
  38.  
  39. /* Define calls if using function pointers or not */
  40. #ifdef FUNCTION_PTRS
  41.   #if (TEX_DIM == 1)
  42.     #ifdef SUBTEXTURE
  43.       #define TEXLOAD_CALL (*copytexsubimage1dext)(target, texLevel, x, srcx, srcy, width);
  44.     #else
  45.       #define TEXLOAD_CALL (*copyteximage1dext)(target, texLevel, comps, srcx, srcy, width, border);
  46.     #endif
  47.   #elif (TEX_DIM == 2)
  48.     #ifdef SUBTEXTURE
  49.       #define TEXLOAD_CALL (*copytexsubimage2dext)(target, texLevel, x, y, srcx, srcy, width, height);
  50.     #else
  51.       #define TEXLOAD_CALL (*copyteximage2dext)(target, texLevel, comps, srcx, srcy, width, height, border);
  52.     #endif
  53.   #elif (TEX_DIM == 3)
  54.     #define TEXLOAD_CALL (*copytexsubimage3dext)(target, texLevel, x, y, z, srcx, srcy, width, height);
  55.   #endif
  56.   #if defined(POINT_DRAW)
  57.     #define VERTEX_CALL  \
  58.       (*texcoord4fv)(point); \
  59.       (*vertex3fv)(point+4);
  60.     #define BEGIN_CALL   (*begin)(GL_POINTS);
  61.     #define END_CALL     (*end)();
  62.   #elif defined(TRI_DRAW)
  63.     #define VERTEX_CALL  \
  64.       (*texcoord4fv)(point); \
  65.       (*vertex3fv)(point+4); \
  66.       (*texcoord4fv)(point+7); \
  67.       (*vertex3fv)(point+11); \
  68.       (*texcoord4fv)(point+14); \
  69.       (*vertex3fv)(point+18);
  70.     #define BEGIN_CALL   (*begin)(GL_TRIANGLE_STRIP);
  71.     #define END_CALL     (*end)();
  72.   #endif
  73. #else
  74.   #if (TEX_DIM == 1)
  75.     #ifdef SUBTEXTURE
  76.       #define TEXLOAD_CALL glCopyTexSubImage1DEXT(target, texLevel, x, srcx, srcy, width);
  77.     #else
  78.       #define TEXLOAD_CALL glCopyTexImage1DEXT(target, texLevel, comps, srcx, srcy, width, border);
  79.     #endif
  80.   #elif (TEX_DIM == 2)
  81.     #ifdef SUBTEXTURE
  82.       #define TEXLOAD_CALL glCopyTexSubImage2DEXT(target, texLevel, x, y, srcx, srcy, width, height);
  83.     #else
  84.       #define TEXLOAD_CALL glCopyTexImage2DEXT(target, texLevel, comps, srcx, srcy, width, height, border);
  85.     #endif
  86.   #elif (TEX_DIM == 3)
  87.     #define TEXLOAD_CALL glCopyTexSubImage3DEXT(target, texLevel, x, y, z, srcx, srcy, width, height);
  88.   #endif
  89.   #if defined(POINT_DRAW)
  90.     #define VERTEX_CALL  \
  91.       glTexCoord4fv(point); \
  92.       glVertex3fv(point+4);
  93.     #define BEGIN_CALL   glBegin(GL_POINTS);
  94.     #define END_CALL     glEnd();
  95.   #elif defined(TRI_DRAW)
  96.     #define VERTEX_CALL  \
  97.       glTexCoord4fv(point); \
  98.       glVertex3fv(point+4); \
  99.       glTexCoord4fv(point+7); \
  100.       glVertex3fv(point+11); \
  101.       glTexCoord4fv(point+14); \
  102.       glVertex3fv(point+18);
  103.     #define BEGIN_CALL   glBegin(GL_TRIANGLE_STRIP);
  104.     #define END_CALL     glEnd();
  105.   #endif
  106. #endif
  107.  
  108. #if defined(POINT_DRAW) || defined(TRI_DRAW)
  109.   #define DEFINE_TRI GLfloat* point = this->triangleData; 
  110.   #define DRAW_OBJ  \
  111.     BEGIN_CALL   \
  112.     VERTEX_CALL  \
  113.     END_CALL
  114. #else
  115.   #define DEFINE_TRI
  116.   #define DRAW_OBJ
  117. #endif
  118.  
  119. #ifdef SUBTEXTURE
  120.   #if (TEX_DIM == 1)
  121.     #define SET_SUBTEXTURE x = *subTexPtr++;
  122.   #elif (TEX_DIM == 2)
  123.     #define SET_SUBTEXTURE x = *subTexPtr++; \
  124.                            y = *subTexPtr++;
  125.   #elif (TEX_DIM == 3)
  126.     #define SET_SUBTEXTURE x = *subTexPtr++; \
  127.                            y = *subTexPtr++; \
  128.                            z = *subTexPtr++;
  129.   #endif
  130. #else
  131.   #define SET_SUBTEXTURE
  132. #endif
  133.   
  134. void FUNCTION (TestPtr thisTest)
  135. {
  136.     TexImagePtr this = (TexImagePtr)thisTest;
  137.     int iterations = this->iterations;
  138.     int numDrawn = this->numDrawn;
  139.     GLenum target = this->texTarget;
  140.     GLenum border = this->texBorder;
  141.     GLenum comps = this->texComps;
  142.     GLint* copyTexData = this->copyTexData;
  143.     GLint* copyTexPtr = copyTexData;
  144.     GLint srcx, srcy;
  145.   #ifdef SUBTEXTURE
  146.     GLint* subTexData = this->subTexData;
  147.     GLint* subTexPtr = subTexData;
  148.     int x;
  149.     int width = this->subTexWidth;
  150.    #if (TEX_DIM >= 2)
  151.     int y;
  152.     int height = this->subTexHeight;
  153.    #endif
  154.    #if (TEX_DIM == 3)
  155.     int z;
  156.    #endif
  157.   #else
  158.     int width = this->texImageWidth;
  159.    #if (TEX_DIM >= 2)
  160.     int height = this->texImageHeight;
  161.    #endif
  162.   #endif
  163.     int i, j;
  164.     int texLevel = this->texLevel;
  165.   #ifdef FUNCTION_PTRS
  166.    #ifdef WIN32
  167.     #define LINK_CONV APIENTRY
  168.    #else
  169.     #define LINK_CONV
  170.    #endif
  171.    #if (TEX_DIM == 1)
  172.     #ifdef SUBTEXTURE
  173.      void (LINK_CONV *copytexsubimage1dext)(GLenum, GLint, GLint, GLint, GLint, GLsizei) = glCopyTexSubImage1DEXT;
  174.     #else
  175.      void (LINK_CONV *copyteximage1dext)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint) = glCopyTexImage1DEXT;
  176.     #endif
  177.    #elif (TEX_DIM == 2)
  178.     #ifdef SUBTEXTURE
  179.      void (LINK_CONV *copytexsubimage2dext)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei) = glCopyTexSubImage2DEXT;
  180.     #else
  181.      void (LINK_CONV *copyteximage2dext)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint) = glCopyTexImage2DEXT;
  182.     #endif
  183.    #elif (TEX_DIM == 3)
  184.     void (LINK_CONV *copytexsubimage3dext)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei) = glCopyTexSubImage3DEXT;
  185.    #endif
  186.    #if defined(POINT_DRAW) || defined(TRI_DRAW)
  187.     void (LINK_CONV *texcoord4fv)(const GLfloat*) = glTexCoord4fv;
  188.     void (LINK_CONV *vertex3fv)(const GLfloat*) = glVertex3fv;
  189.     void (LINK_CONV *begin)(GLenum) = glBegin;
  190.     void (LINK_CONV *end)(void) = glEnd;
  191.    #endif
  192.   #endif
  193.     DEFINE_TRI
  194.  
  195.     for (i = iterations; i > 0; i--) {
  196.     for (j = numDrawn; j > 0; j--) {
  197.         SET_SUBTEXTURE
  198.         srcx = *copyTexPtr++;
  199.         srcy = *copyTexPtr++;
  200.         TEXLOAD_CALL
  201.         DRAW_OBJ
  202.     }
  203.     copyTexPtr = copyTexData;
  204.       #ifdef SUBTEXTURE
  205.         subTexPtr = subTexData;
  206.       #endif
  207.     }
  208. }
  209.  
  210. #undef TEXLOAD_CALL
  211. #undef BEGIN_CALL
  212. #undef END_CALL
  213. #undef VERTEX_CALL
  214. #undef DEFINE_TRI
  215. #undef DRAW_OBJ
  216. #undef SET_SUBTEXTURE
  217.